require(["jquery",'public'],function($,public) {
    //public.headertitle("搜索列表");
    //public.footer(4);
    public.allocator();

    //页面加载完毕
    public.loaded();

    //var search = public.getUrlParam('search');
    //console.log(search);

    var search = window.localStorage.getItem('search');
    //window.localStorage.removeItem('search');

    if(search){
    	getData(search);
    }else{
    	//
    	console.log(search);
    }

    function getData(search){
    	$.ajax({
            async: false,
            type: 'post',
            dataType: 'json',
            data: {search: search},
            url: MODULE+'Index/search',           
        }).success(function (res) {
            console.log(res);
            $('.searchList_title span').html(search);
            var str = '';
            if(res.code == 0){
                res.data.forEach(function(i){
                	str += '<li class="products_item">'
    					+	'<a class="products_item_productInfo_link" href="'+MODULE+'PublicJump/productInfo/id/'+i.goods_id+'">'
    					+		'<div class="products_item_productInfo">'
    					+			'<div class="img_box">'
    					+				'<img src="'+PUBLIC+i.goods_picture_path+'" alt="'+i.goods_picture+'">'
    					+			'</div>'
    					+			'<div class="text_box">'
    					+				'<p>'+i.goods_name+'</p>'
    					+				'<span>￥'+i.goods_price+'</span>'
    					+			'</div>'
    					+		'</div>'
    					+	'</a>'
    					+'</li>';
                });
            }else{
                    str+= '<li class="products_item">'
                        +   '<div class="products_item_productInfo_link">'
                        +       '<p class="search_none">'+res.msg+'</p>'
                        +   '</div>'
                        +'</li>';
            }
            $('.searchList_main').append(str);

            
        }).fail(function (jqXHR, textStatus, errorThrown) {});
    }
})